<?
	$db = GetDefaultConnection();

	if ($jseq!="" || $item1!="" || $item2!="")
	{
		$queryarry = array(
			'JBNH_SEQ' => $jseq,
			'T_PRODUCT_ITEM1' => $item1,
			'T_PRODUCT_ITEM2' => $item2,
		);
		$query=makeWhereQry($queryarry);
	}
	else
	{
		$query = " T_PRODUCT_TOTAL > T_PRODUCT_TRADE ";
	}
	

	$where .= " and ". $query;

	$sql = sprintf("SELECT * "
					.", (select JBNH_NAME FROM TB_JBNH WHERE JBNH_SEQ=a.JBNH_SEQ) as JBNH_NAME "
					.", (select FARM_NAME FROM TB_FARM WHERE FARM_SEQ=a.FARM_SEQ) as FARM_NAME "
					.", (select CODE_NAME FROM TB_CODE WHERE CODE_TYPE='A' AND CODE_CODE1=a.T_PRODUCT_ITEM1 AND CODE_CODE2=0) as ITEM1_NAME "
					.", (select CODE_NAME FROM TB_CODE WHERE CODE_TYPE='A' AND CODE_CODE1=a.T_PRODUCT_ITEM1 AND CODE_CODE2=a.T_PRODUCT_ITEM2) as ITEM2_NAME "
					." FROM TB_PRODUCT_TEMP a where 1=1 and T_PRODUCT_WORKYN='N' %s order by T_PRODUCT_SEQ desc "
					, $where);
	$list = $db->queryList($sql)
?>
<?
	if ($list->getLength() == 0)
	{
?>
                <tr>
                	<td colspan=8>등록된 목록이 없습니다.</td>
                </tr>
<?
	}
	else
	{
		while ($list->hasNext())
		{
			$row = & $list->next();
			$t_product_seq = $row->getNumber('T_PRODUCT_SEQ');
			$jbnh_name = $row->getString('JBNH_NAME');
			$farm_name = $row->getString('FARM_NAME');
			$t_product_country = $row->getString('T_PRODUCT_COUNTRY');
			$item1_name = $row->getString('ITEM1_NAME');
			$item2_name = $row->getString('ITEM2_NAME');
			$t_product_weight2 = $row->getNumber('T_PRODUCT_WEIGHT2');
			$t_product_number = $row->getNumber('T_PRODUCT_NUMBER');
			$t_product_total = $row->getNumber('T_PRODUCT_TOTAL');
			$t_product_date = $row->getString('T_PRODUCT_DATE');
?>
					<tr>
						<td><?=$t_product_date?></td>
						<td><?=$jbnh_name?></td>
						<td><?=$farm_name?></td>
						<td><?=$t_product_country?></td>
						<td><?=$item1_name?></td>
						<td><?=$item2_name?></td>
						<td><?=$t_product_total?>kg</td>
						<td class="start"><a href="#" onClick="window.open('item_manage_sort_write.html?seq=<?=$t_product_seq?>','','width=800,height=600,scrollbars=yes');"><p class="sort_write"><span>선별확인증 등록</span></p></a></td>
					</tr>
<?
		}
	}
?>
